package com.example.communist_app_api.Schedule;

import com.example.communist_app_api.sensitive.SensitiveWordService;
import com.example.communist_app_api.service.MessageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

/**
 * @author Brother Sheng Editor
 * @version 1.0
 * Create by 2023/2/25 23:47
 * 定时任务初始化敏感词库
 */
@Component
public class InitSensitiveWord {

    @Autowired
    private SensitiveWordService sensitiveWordService;
    /**
     * 每小时的6分16秒触发任务
     */
    @Scheduled(cron = "16 6 * * * ?")
    public void handler() {
        sensitiveWordService.refresh();
        System.out.println("敏感词库于："+System.currentTimeMillis()+" 更新了！");
    }
}
